package v3.object.command.servoCommand;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Map;

import text.TextUtil;
import v3.object.STcfg;
import v3.object.command.iCommand;
import v3.object.ship.Ship;
import v3.object.space.Universe;

public class Confirmation extends servoCommand
{
	public static final String separator="\n-----------------------------\n";
	public Confirmation(String ... msg)
	{
		super();
		computerMessage = TextUtil.append("\n[COMPUTER]:",separator,msg);
	}

	private String computerMessage;

	

	@Override
	public boolean realExecute(STcfg cfg, Universe universe, Ship ship, Map<String, iCommand> commands, String[] input)
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String iii="";
		System.out.print(computerMessage+separator+"please confirm [y/n] ->");
		while (true)
		{
	        try
			{
				iii = br.readLine();
				if(iii.equalsIgnoreCase("y") || iii.equalsIgnoreCase("y"))
					return true;

				if(iii.equalsIgnoreCase("n") || iii.equalsIgnoreCase("n"))
					return false;
			}
			catch (IOException e)
			{
				e.printStackTrace();
			}
		}
	}

	@Override
	protected double calculateEnergy(STcfg cfg, Universe universe, Ship ship, Map<String, iCommand> commands, String[] input)
	{
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	protected void checkInput(String[] input) throws Exception
	{
		// TODO Auto-generated method stub
		
	}

	@Override
	protected boolean isCommandAccetable(STcfg cfg, Universe universe, Ship ship, Map<String, iCommand> commands, String[] input)
	{
		return true;
	}



}
